package com.liuf.thread.runable;

/**
 * @author LIUFANG
 */
public class ThreadDemo extends Thread{

    private int ticketCount = 5;

    private String name;

    public ThreadDemo(String name) {
        this.name = name;
    }

    @Override
    public void run(){
        while (ticketCount >0){
            System.out.println("线程的名称="+this.getName()+"剩余几张票="+ticketCount);
            try {
                sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            ticketCount--;
        }
    }

    public static void main(String[] args) throws Exception {
        ThreadDemo demo = new ThreadDemo("Thread线程1");
        ThreadDemo demo2 = new ThreadDemo("Thread线程2");
        ThreadDemo demo3 = new ThreadDemo("Thread线程3");
        demo.start();
        demo2.start();
        demo3.start();
    }
}
